package com.jzo2o.customer.controller.operation;

import cn.hutool.core.bean.BeanUtil;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.dto.request.AgencyCertificationAuditPageQueryReqDTO;
import com.jzo2o.customer.model.dto.request.CertificationAuditReqDTO;
import com.jzo2o.customer.model.dto.response.AgencyCertificationAuditResDTO;
import com.jzo2o.customer.model.dto.response.AgencyCertificationResDTO;
import com.jzo2o.customer.service.IAgencyCertificationService;
import com.jzo2o.mvc.model.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author itcast
 */
@RestController("operationAgencyCertificationController")
@RequestMapping("/operation")
@Api(tags = "运营端 - 机构认证信息相关接口")
public class AgencyCertificationController {

    @Resource
    private IAgencyCertificationService agencyCertificationService;

    @GetMapping("/agency-certification/{id}")
    @ApiOperation("根据机构id查询认证信息")
    public AgencyCertificationResDTO queryById(@PathVariable("id") Long id) {
        return BeanUtil.toBean(agencyCertificationService.getById(id), AgencyCertificationResDTO.class);
    }
    @GetMapping("/agency-certification-audit/page")
    @ApiOperation("审核机构认证分页查询")
    public PageResult<AgencyCertificationAuditResDTO> pageQuery(@ModelAttribute AgencyCertificationAuditPageQueryReqDTO agencyCertificationAuditPageQueryReqDTO) {
        return agencyCertificationService.pageQuery(agencyCertificationAuditPageQueryReqDTO);
    }

    @PutMapping ("/agency-certification-audit/audit/{id}")
    @ApiOperation("审核机构认证信息")
    public Result<Void> auditAgencyCertification(@PathVariable("id") Long id,@RequestBody CertificationAuditReqDTO certificationAuditReqDTO) {
        agencyCertificationService.agencyCertificationAudit(id,certificationAuditReqDTO);
        return Result.ok();
    }
}
